/**
 * Copyright：2020，TLF工作室。
 */
package com.cqeec.netdisc.service;

import java.util.Date;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqeec.netdisc.mapper.UserMapper;
import com.cqeec.netdisc.model.User;

/**
 * 用户服务实现类。
 * 
 * @author 唐礼飞
 * 
 * @date 2020-10-11 10:16:47
 *
 */
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;

	@Override
	public void save(User user) {
		user.setId(UUID.randomUUID().toString().toUpperCase());
		user.setCreationTime(new Date());
		userMapper.insert(user);
	}

	@Override
	public User login(String name, String password) {
		return userMapper.findLoginUser(name, password);
	}

	@Override
	public boolean checkUserPassword(String id, String password) {
		int total = userMapper.checkUserPassword(id, password);
		return total == 0 ? false : true;
	}

	@Override
	public void updatePassword(String id, String password) {
		userMapper.updatePassword(id, password);
	}

}
